using System;
using System.Reflection;
using CommandSystem;

namespace RgCore.GameModes.Commands.GameModeCommands
{
    public class List : ICommand
    {
        public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
        {
            response = "所有游戏模式：";
            foreach (var gamemode in GameMode.AllGameModes)
            {
                var attr = gamemode.GetCustomAttribute<GameModeAttribute>();
                response += $"\n【{attr.Name}】({gamemode.Name}) [{attr.MinPlayerNeeded}, {attr.MaxPlayerLimit}] ";
                if (gamemode == GameMode.DefaultMode)
                    response += "[默认]";
                if (GameMode.CurrentGameMode.GetType() == gamemode)
                    response += "[运行中]";
                if (GameMode.NextGameMode == gamemode)
                    response += "[下回合模式]";
            }

            response += "\n---------------------";
            return true;
        }

        public string Command { get; } = "list";
        public string[] Aliases { get; } = Array.Empty<string>();
        public string Description { get; } = "获取游戏模式列表";
    }
}